home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / BuildingBlocks / LogWindow.cp < prev    next >
Encoding:
Text File  |  1995-07-28  |  17.7 KB  |  773 lines  |  [TEXT/R*ch]

  1. /*
  2.     File:        LogWindow.cp
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #ifndef __LOGWINDOW__
  15. #include "LOGWINDOW.h"
  16. #endif
  17.  
  18. #ifndef __TYPES__
  19. #include <Types.h>
  20. #endif
  21.  
  22. #ifndef __FONTS__
  23. #include "FONTS.h"
  24. #endif
  25.  
  26. #ifndef __MENUS__
  27. #include <Menus.h>
  28. #endif
  29.  
  30. #ifndef __WINDOWS__
  31. #include <Windows.h>
  32. #endif
  33.  
  34. #ifndef __MEMORY__
  35. #include <Memory.h>
  36. #endif
  37.  
  38. #ifndef __LIMITS__
  39. #include <Limits.h>
  40. #endif
  41.  
  42. #ifndef __GRAFPORTSAVER__
  43. #include "GrafPortSaver.h"
  44. #endif
  45.  
  46. #ifndef __ERRORS__
  47. #include <Errors.h>
  48. #endif
  49.  
  50. #ifndef __EVENTS__
  51. #include <Events.h>
  52. #endif
  53.  
  54. #ifndef __OSEVENTS__
  55. #include <OSEvents.h>
  56. #endif
  57.  
  58. #ifndef __STDIO__
  59. #include <stdio.h>
  60. #endif
  61.  
  62. #ifndef __OBJECTLIST__
  63. #include "ObjectList.h"
  64. #endif
  65.  
  66. #ifndef __STRSTREAM__
  67. #include "StrStream.h"
  68. #endif
  69.  
  70. #ifndef __THREADCLASSES__
  71. #include "ThreadClasses.h"
  72. #endif
  73.  
  74. /***********************************|****************************************/
  75.  
  76. DeclareList ( TLogWindow, TLogWindowList );
  77. ImplementList ( TLogWindow, TLogWindowList , true );
  78.  
  79. /***********************************|****************************************/
  80.  
  81. TLogWindowList                        gLogWindowList;
  82.  
  83. /***********************************|****************************************/
  84.  
  85. static VHSelect    gOrthogonal[2] = { h, v };
  86.  
  87. /***********************************|****************************************/
  88.  
  89. static RgnHandle GetSaveVisRgn(void)
  90. {
  91.     const long addr    = 0x09F2;
  92.     
  93.     return * (RgnHandle *) addr;
  94. }
  95.  
  96. /***********************************|****************************************/
  97.  
  98. inline VHSelect LongerSide(Rect& r)
  99. {
  100.     if ((r.bottom - r.top) >= (r.left - r.right))
  101.         return v;
  102.     else
  103.         return h;
  104. }
  105.  
  106. /***********************************|****************************************/
  107.  
  108. TLogWindow::TLogWindow ( short windowID ) :
  109.     fWindowResID ( windowID ),
  110.     fDebugWindowPtr ( nil ),
  111.     fHeight ( 14 ),
  112.     fARgn ( nil ),
  113.  
  114.     fRowCount ( 10 ),
  115.     
  116.     fScrollWindowWhenTextIsAdded ( true )
  117. {
  118.     fSBars [ v ] = fSBars [ h ] = nil;
  119.  
  120.     SetRect(&fStdDrag, 4, 24, qd.screenBits.bounds.right - 4, qd.screenBits.bounds.bottom - 4);    //this is suggested in Inside Macintosh
  121.     SetRect(&fStdSize, 20, 20, qd.screenBits.bounds.right, qd.screenBits.bounds.bottom - 20);        //arbitrary Minimum size; Maximum size is screen
  122.  
  123.     fViewSize.v = fViewSize.h = 0;
  124.  
  125.     gLogWindowList.Append ( this );
  126.     
  127. }
  128.  
  129. /***********************************|****************************************/
  130.  
  131. TLogWindow::~TLogWindow ( )
  132. {
  133.     //    Close the actual window, if it exists.
  134.     if ( fDebugWindowPtr )
  135.         CloseWindow ( fDebugWindowPtr );
  136.     fDebugWindowPtr = nil;
  137.     
  138.     gLogWindowList.Remove ( this );
  139. }
  140.  
  141. /***********************************|****************************************/
  142.  
  143. Boolean TLogWindow::Initialize ( )
  144. {    CGrafPortSaver saver ( nil );
  145.  
  146.     if ( ! fDebugWindowPtr )
  147.     {        
  148.         fDebugWindowPtr = GetNewWindow ( fWindowResID, nil, (WindowPtr) -1 );
  149.         
  150.         FAILNULL ( fDebugWindowPtr );
  151.         
  152.         ((WindowPeek) fDebugWindowPtr)->refCon = (long) this;
  153.     
  154.         fARgn = NewRgn();
  155.     
  156.         //scroll bars
  157.         for ( VHSelect vhs = v; vhs <= h; ++ vhs ) {
  158.             fSBars[vhs] = NewControl(GetWindowPtr(), &GetWindowPtr()->portRect, "\p", false, 0, 0, 1, scrollBarProc, 0);
  159.             (**fSBars[vhs]).contrlRfCon = (long) this;
  160.         }
  161.     
  162.         fScrollOffset.v = fScrollOffset.h = 0;
  163.     
  164.         SetPt(&fViewSize, (2 * kLogWindowHMargin) + 
  165.                                 ( GetRowWidth ( ) ),
  166.                                 (2 * kLogWindowVMargin) + (fHeight * GetRowCount () ) );
  167.     
  168.         //put the scroll bars in the right place
  169.         Grown();
  170.         UpdateEvent();
  171.     
  172.         //scroll to the end, in case there is some information that needs to be displayed
  173.         SetCtlValue(fSBars[v], LONG_MAX);
  174.         DoScrolling();
  175.     }
  176.     
  177.     return true;
  178. }
  179.  
  180. /***********************************|****************************************/
  181.  
  182. void TLogWindow::WindowFocus(void)
  183. {
  184.     SetPort( GetWindowPtr() );
  185.     SetOrigin(0, 0);
  186.     ClipRect(&qd.thePort->portRect);
  187. }
  188.  
  189. /***********************************|****************************************/
  190.  
  191. void TLogWindow::ContentFocus(void)
  192. {    Rect        r;
  193.  
  194.     SetPort( GetWindowPtr() );
  195.     SetOrigin(fScrollOffset.h, fScrollOffset.v);
  196.     * ( Rect *) &r = * ( Rect *) & qd.thePort->portRect;
  197.     r.right = r.right - 15;
  198.     r.bottom = r.bottom - 15;
  199.     ClipRect(&r);
  200. }
  201.  
  202. /***********************************|****************************************/
  203.  
  204. void TLogWindow::ActivateEvent( short modifiers )
  205. {    Rect r;
  206.     CGrafPortSaver saver (  GetWindowPtr()  );
  207.     
  208.     WindowFocus();
  209.  
  210.     r = qd.thePort->portRect;
  211.  
  212.     if ( modifiers & 0x01 )
  213.     {
  214.         ShowControl ( fSBars[v] );
  215.         ShowControl ( fSBars[h] );
  216.     }
  217.     else
  218.     {
  219.         HideControl ( fSBars[v] );
  220.         HideControl ( fSBars[h] );
  221.     }
  222.  
  223.     DrawGrowIcon( GetWindowPtr() );
  224. }
  225.  
  226. /***********************************|****************************************/
  227.  
  228. void TLogWindow::DoScrolling(void)
  229. {    Point newOffset;
  230.     Point delta;
  231.         
  232.     newOffset.v = GetCtlValue(fSBars[v]);
  233.     delta.v = fScrollOffset.v - newOffset.v;
  234.     newOffset.h = GetCtlValue(fSBars[h]);
  235.     delta.h = fScrollOffset.h - newOffset.h;
  236.  
  237.     if ((delta.h != 0) || (delta.v != 0))
  238.     {
  239.         ContentFocus();
  240.  
  241.         ScrollRect(&qd.thePort->portRect, delta.h, delta.v, fARgn);
  242.         fScrollOffset = newOffset;
  243.  
  244.         InvalRgn(fARgn);
  245.  
  246.         UpdateEvent();
  247.     }
  248. }
  249.  
  250. /***********************************|****************************************/
  251.  
  252. void TLogWindow::InsertRow ( unsigned long beforeWhichRow, unsigned long count )
  253. {
  254.     fRowCount += count ;
  255.     for ( unsigned long index = beforeWhichRow ; index <= GetRowCount(); ++ index )
  256.         InvalidateRow ( index );
  257. }
  258.  
  259. /***********************************|****************************************/
  260.  
  261. void TLogWindow::DeleteRow ( unsigned long whichRow, unsigned long count )
  262. {
  263.     for ( unsigned long index = whichRow ; index <= GetRowCount (); ++ index )
  264.         InvalidateRow ( index );
  265.     fRowCount -= count ;
  266. }
  267.  
  268. /***********************************|****************************************/
  269.  
  270. void TLogWindow::Draw ( ) const
  271. {
  272.     if (  GetWindowPtr() ) 
  273.         Draw (  GetWindowPtr() ->portRect );
  274. }
  275.  
  276. /***********************************|****************************************/
  277.  
  278.  
  279. void TLogWindow::Draw( const Rect& drawRect ) const
  280. {    
  281.     for ( unsigned long index = 1; index <= GetRowCount () ; ++ index )
  282.         DrawRow ( index );
  283. }
  284.  
  285. /***********************************|****************************************/
  286.  
  287. void TLogWindow::DrawRow ( unsigned long whichRow ) const
  288. {
  289.     MoveTo ( 2, whichRow * fHeight );
  290.     DrawString ( "\pHi Mom!!  ");
  291. }
  292.  
  293. /***********************************|****************************************/
  294.  
  295. Rect TLogWindow::GetRectForRow ( unsigned long whichRow ) const
  296. {
  297.     Rect result;
  298.     result.top = kLogWindowVMargin + ( whichRow - 1 ) * fHeight;
  299.     result.left = kLogWindowHMargin;
  300.     result.bottom = result.top + fHeight;
  301.     result.right = kLogWindowHMargin + GetRowWidth();
  302.     
  303.     return result;
  304. }
  305.  
  306. /***********************************|****************************************/
  307.  
  308. void TLogWindow::ValidateRow ( unsigned long whichRow ) const
  309. {
  310.     Rect r = GetRectForRow ( whichRow );
  311.     CGrafPortSaver saver (  GetWindowPtr()  );
  312.     ValidRect ( &r );
  313. }
  314.  
  315. /***********************************|****************************************/
  316.  
  317. void TLogWindow::InvalidateRow ( unsigned long whichRow ) const
  318. {
  319.     Rect r = GetRectForRow ( whichRow );
  320.     CGrafPortSaver saver (  GetWindowPtr()  );
  321.     InvalRect ( &r );
  322. }
  323.  
  324. /***********************************|****************************************/
  325.  
  326. unsigned long TLogWindow::GetRowCount ( ) const
  327. {
  328.     return fRowCount;
  329. }
  330.  
  331. /***********************************|****************************************/
  332.  
  333. unsigned long TLogWindow::GetRowWidth ( ) const
  334. {
  335.     return 200;
  336. }
  337.  
  338. /***********************************|****************************************/
  339.  
  340. void TLogWindow::Grown(void)
  341. {    Rect        r;
  342.     ControlHandle        anSBar;
  343.     short        newMax;
  344.     CGrafPortSaver saver (  GetWindowPtr()  );
  345.  
  346.     WindowFocus();
  347.     SetRect (&r, 0, 0, 0, 0 );
  348.     ClipRect(&r);
  349.  
  350.     for (VHSelect vhs = v; vhs <= h; ++vhs )
  351.     {
  352.         anSBar = fSBars[vhs];
  353.  
  354.         r = qd.thePort->portRect;
  355.  
  356.         // Calculate new position of scroll bar
  357.         (( short *) &r.top)[vhs] = (( short *) &r.top)[vhs] - 1;
  358.         (( short *) &r.top)[gOrthogonal[vhs]] = (( short *) &r.bottom)[gOrthogonal[vhs]] - 15;
  359.         (( short *) &r.bottom)[vhs] = (( short *) &r.bottom)[vhs] - 14;
  360.         (( short *) &r.bottom)[gOrthogonal[vhs]] = (( short *) &r.top)[gOrthogonal[vhs]] + 16;
  361.  
  362.         //Move the scroll bar
  363.         MoveControl(anSBar, r.left, r.top);
  364.         SizeControl(anSBar, r.right-r.left, r.bottom-r.top);
  365.  
  366.         if ( vhs == v )
  367.             newMax = fViewSize.v - (r.bottom - r.top);
  368.         else
  369.             newMax = fViewSize.h - (r.right - r.left );
  370.         
  371.         if (newMax < 0)
  372.             newMax = 0;
  373.         SetCtlMax(anSBar, newMax);
  374.     }
  375.  
  376.     InvalidateGrowBox();
  377.  
  378.     DoScrolling();    //in case we are showing too much white space
  379. }
  380.  
  381. /***********************************|****************************************/
  382.  
  383. void TLogWindow::InvalidateGrowBox ( ) const
  384. {    Rect     r;
  385.  
  386.     r = qd.thePort->portRect;
  387.     r.top = r.bottom - 15;
  388.     r.left = r.right - 15;
  389.  
  390.     InvalRect(&r);
  391. }
  392.  
  393. /***********************************|****************************************/
  394.  
  395. Boolean GetDefaultWindowInformation ( short dialogID, Boolean& visible, Rect & screenRect );
  396. Boolean SetDefaultWindowInformation ( DialogPtr dP, short dialogID );
  397.  
  398. /***********************************|****************************************/
  399.  
  400. void TLogWindow::MouseDown(short where, Point pt, short modifiers)
  401. {    GrafPtr        savePort;
  402.     CGrafPortSaver saver (  GetWindowPtr()  );
  403.         
  404.     switch (where) {
  405.         case inDrag:
  406.             DragWindow( GetWindowPtr() , pt, &fStdDrag);
  407.             break;
  408.             
  409.         case inGrow:
  410.             WindowFocus();
  411.  
  412.             long frowResult = GrowWindow( GetWindowPtr() , pt, &fStdSize);
  413.             if (frowResult != 0)
  414.             {    short newH = (short) (frowResult & 0xffff );
  415.                 short newV = (short) (frowResult >> 16);
  416.                 
  417.                 InvalidateGrowBox();
  418.                 SizeWindow( GetWindowPtr() , newH, newV, true);
  419.                 SetDefaultWindowInformation (  GetWindowPtr() , -1 );
  420.  
  421.                 Grown();
  422.             }
  423.             break;
  424.             
  425.         case inGoAway:
  426.             if (TrackGoAway( GetWindowPtr() , pt)) {
  427.                 SetDefaultWindowInformation (  GetWindowPtr() , -1 );
  428.                 HideWindow( GetWindowPtr() );
  429.             }
  430.             break;
  431.             
  432.         case inContent:
  433.             if ( GetWindowPtr()  == FrontWindow())
  434.             {
  435.                 WindowFocus();
  436.                 GlobalToLocal(&pt);
  437.                 
  438.                 ControlHandle whichControl;
  439.                 long partCode = FindControl(pt,  GetWindowPtr() , &whichControl);
  440.                 switch (partCode) 
  441.                 {
  442.                     case inUpButton:
  443.                     case inDownButton:
  444.                     case inPageUp:
  445.                     case inPageDown:
  446.                         pascal void LogWindowTrackControlCallback ( ControlHandle aControl, short partCode );
  447.                         partCode = TrackControl(whichControl, pt, NewControlActionProc((ProcPtr) &LogWindowTrackControlCallback));
  448.                         DoScrolling();
  449.                         WindowFocus();
  450.                         break;
  451.                         
  452.                     case inThumb:
  453.                         partCode = TrackControl(whichControl, pt, NULL);
  454.                         DoScrolling();
  455.                         break;
  456.                     
  457.                     case 0:
  458.                         break;
  459.                 }
  460.             }
  461.             else
  462.                 SelectWindow( GetWindowPtr() );
  463.                 
  464.             break;            
  465.     }
  466. }
  467.  
  468. /***********************************|****************************************/
  469.  
  470. void TLogWindow::Scroll ( short howManyLines )
  471. {    CGrafPortSaver saver (  GetWindowPtr()  );
  472.  
  473.     short val = GetCtlValue(fSBars[v]);
  474.     if (((howManyLines < 0) && (val > GetCtlMin(fSBars[v]))) ||
  475.        ((howManyLines > 0) && (val < GetCtlMax(fSBars[v]))))
  476.     {
  477.         SetCtlValue(fSBars[v], val + howManyLines * fHeight);
  478.         DoScrolling();
  479.     }
  480. }
  481.  
  482. /***********************************|****************************************/
  483.  
  484. void TLogWindow::ShowPoint(Point pt)
  485. {    Point     minToSee;
  486.         short        deltaCd;
  487.  
  488.     if ( GetWindowPtr()  != NULL)
  489.     {
  490.         WindowFocus();
  491.  
  492.         SetPt(&minToSee, 50, fHeight);
  493.  
  494.         // the following code is actually better than writing a loop with VHSelect
  495.         deltaCd = pt.v + minToSee.v - (qd.thePort->portRect.bottom - 15 + fScrollOffset.v);
  496.         if (deltaCd <= 0)
  497.         {
  498.             deltaCd = pt.v - minToSee.v - (qd.thePort->portRect.top + fScrollOffset.v);
  499.             if (deltaCd >= 0)
  500.                 deltaCd = 0;
  501.         }
  502.         SetCtlValue(fSBars[v], GetCtlValue(fSBars[v]) + deltaCd);
  503.  
  504.         deltaCd = pt.h + minToSee.h - (qd.thePort->portRect.right - 15 + fScrollOffset.h);
  505.         if (deltaCd <= 0)
  506.         {
  507.             deltaCd = pt.h - minToSee.h - (qd.thePort->portRect.left + fScrollOffset.h);
  508.             if (deltaCd >= 0)
  509.                 deltaCd = 0;
  510.         }
  511.         SetCtlValue(fSBars[h], GetCtlValue(fSBars[h]) + deltaCd);
  512.  
  513.         DoScrolling();
  514.     }
  515. }
  516.  
  517. /***********************************|****************************************/
  518.  
  519. pascal void LogWindowTrackControlCallback ( ControlHandle aControl, short partCode )
  520. {
  521.     if (partCode != 0)
  522.     {
  523.         TLogWindow* logWindow = (TLogWindow *) (**aControl).contrlRfCon;
  524.         
  525.         Boolean up = (partCode == inUpButton) || (partCode == inPageUp);
  526.         short ctlValue = GetCtlValue(aControl);
  527.  
  528.         //    Avoid flicker in setting thumb, if (user tries to scroll past end
  529.         if ((up && (ctlValue > GetCtlMin(aControl))) ||
  530.            (!up && (ctlValue < GetCtlMax(aControl))))
  531.         {
  532.             Rect r = (*aControl)->contrlRect;   //    heap may compact when we call LongerSide
  533.             VHSelect vhs = LongerSide(r);        //    this tells us which way we are scrolling
  534.  
  535.             short delta = 10;
  536.             
  537.             if ( logWindow )
  538.             {    WindowPtr ourWindow = logWindow->GetWindowPtr();
  539.             
  540.                 if ((partCode == inPageUp) || (partCode == inPageDown) && ourWindow )
  541.                     if ( vhs == v )
  542.                         delta = ourWindow->portRect.bottom - ourWindow->portRect.top;
  543.                     else
  544.                         delta = ourWindow->portRect.right - ourWindow->portRect.left;
  545.                 else
  546.                     delta = logWindow->fHeight;
  547.             }
  548.             
  549.             if (up)
  550.                 delta = - delta;
  551.  
  552.             SetCtlValue(aControl, ctlValue + delta);
  553.             
  554.             if ( logWindow )
  555.             {
  556.                 logWindow->DoScrolling();
  557.                 logWindow->WindowFocus();
  558.             }
  559.         }
  560.     }
  561. }
  562.  
  563. /***********************************|****************************************/
  564.  
  565. static Rect GetRegionBoundingRect ( RgnHandle rgn )
  566. {    
  567.     if ( rgn )
  568.         return ( ** rgn ).rgnBBox;
  569.     Rect r = { -32767, -32767, 32767, 32767 };
  570.     return r;
  571. }
  572.  
  573. /***********************************|****************************************/
  574.  
  575. void TLogWindow::UpdateEvent(void)
  576. {    GrafPtr         savePort;
  577.     RgnHandle        saveSaveVisRgn;
  578.     RgnHandle        saveVisRgn;
  579.  
  580.     if (( GetWindowPtr()  != NULL) &&
  581.         (!EmptyRgn( ((WindowPeek)  GetWindowPtr() )->port.visRgn))) 
  582.     {    CGrafPortSaver saver (  GetWindowPtr()  );
  583.     
  584.         saveSaveVisRgn = NewRgn();
  585.         saveVisRgn = GetSaveVisRgn();
  586.  
  587.         CopyRgn(saveVisRgn, saveSaveVisRgn);
  588.  
  589.         BeginUpdate( GetWindowPtr() );
  590.  
  591.         WindowFocus();
  592.  
  593.         EraseRect(&qd.thePort->portRect);
  594.  
  595.         DrawGrowIcon( GetWindowPtr() );
  596.         DrawControls( GetWindowPtr() );
  597.  
  598.         ContentFocus();
  599.         
  600.         Rect updateRect = GetRegionBoundingRect (  GetWindowPtr() ->visRgn );
  601.         
  602.         Draw( );
  603.  
  604.         EndUpdate( GetWindowPtr() );
  605.  
  606.         CopyRgn(saveSaveVisRgn, saveVisRgn);
  607.         DisposeRgn(saveSaveVisRgn);
  608.     }
  609. }
  610.  
  611. /***********************************|****************************************/
  612.  
  613. WindowPtr TLogWindow::GetWindowPtr ( ) const
  614. {
  615.     if ( ! fDebugWindowPtr )
  616.         ((TLogWindow *) this )->Initialize () ;
  617.         
  618.     return fDebugWindowPtr ;
  619. }
  620.  
  621. /***********************************|****************************************/
  622.  
  623. static TLogWindow* FindLogWindow ( WindowPtr wP )
  624. {
  625.     for ( unsigned long index = 1; index <= gLogWindowList.Count (); ++ index )
  626.         if ( gLogWindowList.Get ( index )->GetWindowPtr() == wP )
  627.             return gLogWindowList.Get ( index );
  628.         
  629.     return nil;
  630. }
  631.  
  632. /***********************************|****************************************/
  633.  
  634. /*
  635. --    Paul's Writeln routines  ----------------------------------------------------------------
  636. */
  637. Boolean TLogWindow::IsLogWindowEvent (const EventRecord& event )
  638. {
  639.     Boolean        result = false;
  640.  
  641.     switch ( event.what )
  642.     {
  643.         case mouseDown:
  644.         {
  645.             {    WindowPtr        WindowPointedTo;        //window where the mouse is
  646.                 Point MouseLoc = event.where;
  647.  
  648.                 short WindoPart = FindWindow(MouseLoc, &WindowPointedTo);
  649.                 TLogWindow* logWindow = FindLogWindow ( WindowPointedTo );
  650.                 
  651.                 if ( logWindow )
  652.                 {
  653.                     if (WindowPointedTo != FrontWindow())
  654.                         SelectWindow(WindowPointedTo);
  655.                     else
  656.                         logWindow->MouseDown(WindoPart, MouseLoc, event.modifiers);
  657.                     result = true;
  658.                 }
  659.             }
  660.             break;
  661.         }
  662.             
  663.         case activateEvt:
  664.         {    TLogWindow* logWindow = FindLogWindow ( WindowPtr(event.message) );
  665.             if ( logWindow )
  666.             {
  667.                 logWindow->ActivateEvent ( event.modifiers );
  668.                 result = true;
  669.             }
  670.             break;
  671.         }
  672.             
  673.         case updateEvt:
  674.         {    TLogWindow* logWindow = FindLogWindow ( WindowPtr( event.message ) );
  675.             if ( logWindow )
  676.             {
  677.                 logWindow->UpdateEvent();
  678.                 result = true;
  679.             }
  680.             break;
  681.         }
  682.     }
  683.     
  684.     return result;
  685.     
  686. } //Event
  687.  
  688. /***********************************|****************************************/
  689.  
  690. void TLogWindow::Show (void) const
  691. {
  692.     if ( !  GetWindowPtr()  )
  693.         ((TLogWindow *)this )->Initialize ( );
  694.         
  695.     SetDefaultWindowInformation (  GetWindowPtr() , -1 );
  696.  
  697.     ShowWindow ( GetWindowPtr() );
  698. }
  699.  
  700. /***********************************|****************************************/
  701.  
  702. void TLogWindow::Hide (void) const
  703. {
  704.     if ( GetWindowPtr()  )
  705.     {
  706.         SetDefaultWindowInformation (  GetWindowPtr() , -1 );
  707.  
  708.         HideWindow ( GetWindowPtr() );
  709.     }
  710. }
  711.  
  712. /***********************************|****************************************/
  713.  
  714. void DrawString ( short x, short y, TRString s )
  715. {
  716.     MoveTo ( x, y );
  717.     if ( s.GetScript () == smRoman )
  718.         DrawText ( (Ptr) (const char *) s , 0, s.GetLength() );
  719. }
  720.  
  721. /***********************************|****************************************/
  722.  
  723. /***********************************|****************************************/
  724.  
  725. void DrawString ( short x, short y, StringPtr s )
  726. {
  727.     MoveTo ( x, y );
  728.     DrawString ( s );
  729. }
  730.  
  731. /***********************************|****************************************/
  732.  
  733. void DrawNumber ( short x, short y, long n )
  734. {    char    buffer[16];
  735.     sprintf ( buffer, "%d", n );
  736.  
  737.     MoveTo ( x, y );
  738.     DrawText ( & buffer, 0, strlen ( buffer ) );
  739. }
  740.  
  741. /***********************************|****************************************/
  742.  
  743. void EraseLineTo ( short x, short y )
  744. {
  745.     Point pt;
  746.     GetPen ( &pt );
  747.     
  748.     Rect r;
  749.     r.top = y - 10;
  750.     r.bottom = y + 2;
  751.     r.left = pt.h;
  752.     r.right = x;
  753.     
  754.     EraseRect ( &r );
  755. }
  756.  
  757. /***********************************|****************************************/
  758.  
  759. void EraseLineToDrawString ( short x, short y, StringPtr s )
  760. {
  761.     EraseLineTo ( x, y );
  762.     DrawString ( x, y, s );
  763. }
  764.  
  765. /***********************************|****************************************/
  766.  
  767. void EraseLineToDrawNumber ( short x, short y, long n )
  768. {
  769.     EraseLineTo ( x, y );
  770.     DrawNumber ( x, y, n );
  771. }
  772.  
  773.